package codename.carrot.bomberman.game.gamemessages;

/**
 * A networkmessage representing a game-join request by a player
 * @author Gruppe A4
 *
 */
public class PlayerJoinMessage extends BombermanMessage {	
	/**
	 * the UID for serialization
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * The nickname of the player
	 */
    private String nickName;
    /**
     * Specifying whether or not this message is intended for the receiver, and only the receiver
     * If true, then the purpose of this message is only to tell the player which ID it has been assigned to have
     */
    private boolean concernsReceiver;
    
    /**
     *  Constructor
     * @param nickName the nickname of the player that joins the game
     */
    public PlayerJoinMessage(String nickName) {
        this.nickName = nickName;
    }
    
    /**
     * Constructor
     * @param playerId the ID of the player that joined the game
     * @param nickName the nickname of the player that joined the game
     * @param concernsReceiver specifies whether this message is only intended for the receiver or not
     */
    public PlayerJoinMessage(int playerId, String nickName, boolean concernsReceiver) {
        setPlayerId(playerId);
        this.nickName = nickName;
        this.concernsReceiver = concernsReceiver;
    }
    
    /**
     * Sets whether or not this message is intended for the player receiving this message
     * @param concernsReceiver if true, the receiver should be the only one receiving the message
     */
    public void setConcernsReceiver(boolean concernsReceiver) {
        this.concernsReceiver = concernsReceiver;
    }
    
    /**
     *  Returns true if this message is intended for the receiver
     * @return true|false
     */
    public boolean concernsReceiver() {
        return concernsReceiver;
    }
    
    /**
     *  Returns the nickname of the player that sent this message
     * @return the nickname
     */
    public String getPlayerNickname() {
        return nickName;
    }
    
    @Override
	public Object clone() {
		PlayerJoinMessage pjm = new PlayerJoinMessage(this.nickName);
		pjm.setConcernsReceiver(this.concernsReceiver);
		pjm.setPlayerId(getPlayerId());
		return pjm;
	}

}
